From 13120ccf9d96b50b47039742a0f24a537fc496a1 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 20 Apr 2023 23:26:49 +0200 Subject: [PATCH] surface: Make gdk_surface_set_frame_clock() available ... to backends. That way, frame clocks can be constructed by the backends' surface implementations and dont need to be passed in as construct arguments. Also add an assertion that they are indeed constructed. --- gdk/gdksurface.c | 16 ++++++++++++---- gdk/gdksurfaceprivate.h | 2 ++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index e58681764a..209ae3080d 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -115,9 +115,6 @@ static void gdk_surface_get_property (GObject *object, static void update_cursor (GdkDisplay *display, GdkDevice *device); -static void gdk_surface_set_frame_clock (GdkSurface *surface, - GdkFrameClock *clock); - static void gdk_surface_queue_set_is_mapped (GdkSurface *surface, gboolean is_mapped); @@ -496,11 +493,22 @@ gdk_surface_real_get_scale (GdkSurface *surface) return 1.0; } +static void +gdk_surface_constructed (GObject *object) +{ + G_GNUC_UNUSED GdkSurface *surface = GDK_SURFACE (object); + + g_assert (surface->frame_clock != NULL); + + G_OBJECT_CLASS (gdk_surface_parent_class)->constructed (object); +} + static void gdk_surface_class_init (GdkSurfaceClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + object_class->constructed = gdk_surface_constructed; object_class->finalize = gdk_surface_finalize; object_class->set_property = gdk_surface_set_property; object_class->get_property = gdk_surface_get_property; @@ -2452,7 +2460,7 @@ gdk_surface_resume_events (GdkFrameClock *clock, } } -static void +void gdk_surface_set_frame_clock (GdkSurface *surface, GdkFrameClock *clock) { diff --git a/gdk/gdksurfaceprivate.h b/gdk/gdksurfaceprivate.h index a8587a8442..58264697fc 100644 --- a/gdk/gdksurfaceprivate.h +++ b/gdk/gdksurfaceprivate.h @@ -285,6 +285,8 @@ void gdk_surface_get_geometry (GdkSurface *surface, int *width, int *height); +void gdk_surface_set_frame_clock (GdkSurface *surface, + GdkFrameClock *clock); void gdk_surface_set_egl_native_window (GdkSurface *self, gpointer native_window); void gdk_surface_ensure_egl_surface (GdkSurface *self, -- 2.30.2